#include <iostream>
#include <unistd.h>
#include <pthread.h>

//新线程
void* run(void* args)
{
    while(true)
    {
        std::cout<< "new thread, pid" <<getpid() <<std::endl;
        sleep(1);
    }

    return nullptr;
}

int main()
{
    std::cout<< "我是一个进程: "<<getpid()<< std::endl;
    pthread_t tid;
    pthread_create(&tid, nullptr, run, (void*)"thread-l");

    //主线程
    while(true)
    {
        std::cout<< "main thread, pid:" << getpid()<<std::endl;
        sleep(1);
    }

    return 0;
}